import { defHttp } from '/@/utils/http/axios';
import { ApiPrefix } from '/@/settings/sysApis';

const Api = {
  Messages: `${ApiPrefix}/blog/messages`,
};

/**
 * 获取留言列表
 */
export const getList = (params) => {
  return defHttp.get({
    url: `${Api.Messages}/list`,
    params,
  });
};

/**
 * 删除留言
 */
export const deleteOne = (params, handleSuccess) => {
  return defHttp.delete({
    url: `${Api.Messages}/delete`,
    params,
  }).then(() => {
    handleSuccess();
  });
};

/**
 * 批量删除留言
 */
export const deleteBatch = (params, handleSuccess) => {
  return defHttp.delete({
    url: `${Api.Messages}/deleteBatch`,
    params,
  }).then(() => {
    handleSuccess();
  });
};

/**
 * 更新留言状态
 */
export const updateOne = (params) => {
  return defHttp.put({
    url: `${Api.Messages}/edit`,
    data: params,
  });
};

/**
 * 获取导入URL
 */
export const getImportUrl = (callback) => {
  callback(`${Api.Messages}/importExcel`);
};

/**
 * 获取导出URL
 */
export const getExportUrl = (currentRoute, callback) => {
  callback(`${Api.Messages}/exportXls`);
};

/**
 * 复制留言
 */
export const duplicate = (params, handleSuccess) => {
  return defHttp.post({
    url: `${Api.Messages}/duplicate`,
    data: params,
  }).then(() => {
    handleSuccess();
  });
}; 